package com.hmall.common.client;

import com.hmall.common.dto.ItemDTO;
import com.hmall.common.dto.PageDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

@org.springframework.cloud.openfeign.FeignClient("itemservice")
public interface FeignClient {


    /**
     * 分页查询商品信息搜索服务
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/item/findByPage")
    PageDTO<ItemDTO> findByPage4Search(
            @RequestParam(name = "page")Integer page,
            @RequestParam(name = "size")Integer size);

    /**
     * 根据主键id查询
     * @param id
     * @return
     */
    @GetMapping("/item/getById/{id}")
    ItemDTO getById(@PathVariable(name = "id")Long id);


    /**
     * 远程调用更新库存
     * @param itemId
     * @param num
     */
    @PutMapping("/item/stock/{itemId}/{num}")
    void updateStock(@PathVariable("itemId") Long itemId,
                     @PathVariable("num") Integer num);

    /**
     * 远程调用恢复库存
     * @param itemId
     * @param num
     */
    @PutMapping("/item/restoreStock/{itemId}/{num}")
    void restoreStock(@PathVariable("itemId") Long itemId,
                     @PathVariable("num") Integer num);
}